using System;
using System.Collections.Generic;
using System.Text;
using NHibernate;
using Atom.Data.BusinessObjects;
using Atom.Data.Base;

namespace Atom.Data.ManagerObjects
{
    public partial interface IIBalanceRecordManager : IManagerBase<Atom.Data.BusinessObjects.IBalanceRecord, string>
    {
		// Get Methods
		IBalanceRecord GetById(System.String balanceid, System.Int32 trantype);
    }

    partial class IBalanceRecordManager : ManagerBase<Atom.Data.BusinessObjects.IBalanceRecord, string>, IIBalanceRecordManager
    {
		#region Constructors
		
		public IBalanceRecordManager() : base()
        {
        }
        public IBalanceRecordManager(INHibernateSession session) : base(session)
        {
        }
		
		#endregion
		
        #region Get Methods

		public override IBalanceRecord GetById(string id)
		{
			string[] keys = id.Split('^');
			
			if(keys.Length != 2)
				throw new Exception("Invalid Id for IBalanceRecordManager.GetById");
			
			return GetById(keys[0], System.Int32.Parse(keys[1]));
		}
		public IBalanceRecord GetById(System.String balanceid, System.Int32 trantype)
		{
			ICriteria criteria = Session.GetISession().CreateCriteria(typeof(IBalanceRecord));
			
			criteria.Add(NHibernate.Criterion.Expression.Eq("Balanceid", balanceid));
			criteria.Add(NHibernate.Criterion.Expression.Eq("Trantype", trantype));
			
			IBalanceRecord result = (IBalanceRecord)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
		}
		
		
		#endregion
    }
}